home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9323 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  4.4 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news text default
99% file C++ source text default
98% file C++ source, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 63 73 | 2e 74 75 2d 62 65 72 6c |Path: cs|.tu-berl|
|00000010| 69 6e 2e 64 65 21 68 6f | 6d 62 72 65 21 77 6f 6c |in.de!ho|mbre!wol|
|00000020| 66 72 6f 0a 46 72 6f 6d | 3a 20 52 6f 6d 61 6e 20 |fro.From|: Roman |
|00000030| 4c 65 63 68 74 63 68 69 | 6e 73 6b 79 20 3c 77 6f |Lechtchi|nsky <wo|
|00000040| 6c 66 72 6f 40 63 73 2e | 74 75 2d 62 65 72 6c 69 |lfro@cs.|tu-berli|
|00000050| 6e 2e 64 65 3e 0a 4e 65 | 77 73 67 72 6f 75 70 73 |n.de>.Ne|wsgroups|
|00000060| 3a 20 63 6f 6d 70 2e 6c | 61 6e 67 2e 63 2b 2b 0a |: comp.l|ang.c++.|
|00000070| 53 75 62 6a 65 63 74 3a | 20 52 65 3a 20 4f 76 65 |Subject:| Re: Ove|
|00000080| 72 6c 6f 61 64 65 64 20 | 56 69 72 74 75 61 6c 20 |rloaded |Virtual |
|00000090| 66 75 6e 63 74 69 6f 6e | 73 0a 44 61 74 65 3a 20 |function|s.Date: |
|000000a0| 46 72 69 2c 20 31 20 4d | 61 72 20 31 39 39 36 20 |Fri, 1 M|ar 1996 |
|000000b0| 30 31 3a 35 36 3a 33 35 | 20 2b 30 31 30 30 0a 4f |01:56:35| +0100.O|
|000000c0| 72 67 61 6e 69 7a 61 74 | 69 6f 6e 3a 20 54 65 63 |rganizat|ion: Tec|
|000000d0| 68 6e 69 63 61 6c 20 55 | 6e 69 76 65 72 73 69 74 |hnical U|niversit|
|000000e0| 79 20 6f 66 20 42 65 72 | 6c 69 6e 2c 20 47 65 72 |y of Ber|lin, Ger|
|000000f0| 6d 61 6e 79 0a 4d 65 73 | 73 61 67 65 2d 49 44 3a |many.Mes|sage-ID:|
|00000100| 20 3c 50 69 6e 65 2e 53 | 4f 4c 2e 33 2e 39 31 2e | <Pine.S|OL.3.91.|
|00000110| 39 36 30 33 30 31 30 31 | 35 33 35 32 2e 31 33 38 |96030101|5352.138|
|00000120| 38 35 41 2d 31 30 30 30 | 30 30 40 68 6f 6d 62 72 |85A-1000|00@hombr|
|00000130| 65 2e 63 73 2e 74 75 2d | 62 65 72 6c 69 6e 2e 64 |e.cs.tu-|berlin.d|
|00000140| 65 3e 0a 52 65 66 65 72 | 65 6e 63 65 73 3a 20 3c |e>.Refer|ences: <|
|00000150| 39 36 30 32 32 39 31 36 | 35 38 2e 41 41 31 33 36 |96022916|58.AA136|
|00000160| 31 37 40 62 6d 73 69 2e | 63 6f 6d 3e 0a 4e 4e 54 |17@bmsi.|com>.NNT|
|00000170| 50 2d 50 6f 73 74 69 6e | 67 2d 48 6f 73 74 3a 20 |P-Postin|g-Host: |
|00000180| 68 6f 6d 62 72 65 2e 63 | 73 2e 74 75 2d 62 65 72 |hombre.c|s.tu-ber|
|00000190| 6c 69 6e 2e 64 65 0a 4d | 69 6d 65 2d 56 65 72 73 |lin.de.M|ime-Vers|
|000001a0| 69 6f 6e 3a 20 31 2e 30 | 0a 43 6f 6e 74 65 6e 74 |ion: 1.0|.Content|
|000001b0| 2d 54 79 70 65 3a 20 54 | 45 58 54 2f 50 4c 41 49 |-Type: T|EXT/PLAI|
|000001c0| 4e 3b 20 63 68 61 72 73 | 65 74 3d 55 53 2d 41 53 |N; chars|et=US-AS|
|000001d0| 43 49 49 0a 49 6e 2d 52 | 65 70 6c 79 2d 54 6f 3a |CII.In-R|eply-To:|
|000001e0| 20 3c 39 36 30 32 32 39 | 31 36 35 38 2e 41 41 31 | <960229|1658.AA1|
|000001f0| 33 36 31 37 40 62 6d 73 | 69 2e 63 6f 6d 3e 0a 0a |3617@bms|i.com>..|
|00000200| 4f 6e 20 32 39 20 46 65 | 62 20 31 39 39 36 2c 20 |On 29 Fe|b 1996, |
|00000210| 53 74 75 61 72 74 20 44 | 2e 20 47 61 74 68 6d 61 |Stuart D|. Gathma|
|00000220| 6e 20 77 72 6f 74 65 3a | 0a 0a 3e 20 49 6e 20 61 |n wrote:|..> In a|
|00000230| 72 74 69 63 6c 65 20 3c | 34 68 30 66 65 6c 24 70 |rticle <|4h0fel$p|
|00000240| 72 75 40 6e 65 77 73 2e | 63 73 2e 74 75 2d 62 65 |ru@news.|cs.tu-be|
|00000250| 72 6c 69 6e 2e 64 65 3e | 20 79 6f 75 20 77 72 69 |rlin.de>| you wri|
|00000260| 74 65 3a 0a 3e 20 3e 72 | 65 69 6d 70 6c 65 6d 65 |te:.> >r|eimpleme|
|00000270| 6e 74 65 64 20 66 75 6e | 63 74 69 6f 6e 2e 20 54 |nted fun|ction. T|
|00000280| 68 61 74 20 6d 65 61 6e | 73 20 79 6f 75 20 6e 65 |hat mean|s you ne|
|00000290| 65 64 20 61 20 71 75 61 | 6c 69 66 69 65 72 3a 20 |ed a qua|lifier: |
|000002a0| 73 69 6d 70 6c 79 20 72 | 65 70 6c 61 63 65 20 62 |simply r|eplace b|
|000002b0| 2e 70 72 69 6e 74 28 70 | 29 0a 3e 20 3e 62 79 20 |.print(p|).> >by |
|000002c0| 62 2e 41 3a 3a 70 72 69 | 6e 74 28 70 29 2c 20 69 |b.A::pri|nt(p), i|
|000002d0| 2e 65 2e 20 74 65 6c 6c | 20 74 68 65 20 63 6f 6d |.e. tell| the com|
|000002e0| 70 69 6c 65 72 20 74 6f | 20 63 61 6c 6c 20 41 27 |piler to| call A'|
|000002f0| 73 20 66 75 6e 63 74 69 | 6f 6e 2e 20 0a 3e 20 3e |s functi|on. .> >|
|00000300| 49 20 74 68 69 6e 6b 20 | 74 68 69 73 20 69 73 20 |I think |this is |
|00000310| 61 20 73 65 72 69 6f 75 | 73 20 77 65 61 6b 6e 65 |a seriou|s weakne|
|00000320| 73 73 20 6f 66 20 74 68 | 65 20 6c 61 6e 67 75 61 |ss of th|e langua|
|00000330| 67 65 20 73 69 6e 63 65 | 20 74 68 65 20 75 6e 69 |ge since| the uni|
|00000340| 71 75 65 20 69 64 65 6e | 74 69 66 69 65 72 20 6f |que iden|tifier o|
|00000350| 66 20 0a 3e 20 3e 61 20 | 66 75 6e 63 74 69 6f 6e |f .> >a |function|
|00000360| 20 69 73 20 28 20 6f 72 | 20 73 68 6f 75 6c 64 20 | is ( or| should |
|00000370| 62 65 20 29 20 69 74 73 | 20 6e 61 6d 65 20 61 6e |be ) its| name an|
|00000380| 64 20 74 68 65 20 74 79 | 70 65 73 20 6f 66 20 69 |d the ty|pes of i|
|00000390| 74 73 20 61 72 67 75 6d | 65 6e 74 73 2e 20 54 68 |ts argum|ents. Th|
|000003a0| 75 73 2c 20 74 68 65 0a | 3e 20 3e 66 75 6e 63 74 |us, the.|> >funct|
|000003b0| 69 6f 6e 73 20 70 72 69 | 6e 74 28 69 6e 74 29 20 |ions pri|nt(int) |
|000003c0| 61 6e 64 20 70 72 69 6e | 74 28 63 6f 6e 73 74 26 |and prin|t(const&|
|000003d0| 20 54 29 20 73 68 6f 75 | 6c 64 6e 27 74 20 62 65 | T) shou|ldn't be|
|000003e0| 20 72 65 6c 61 74 65 64 | 20 61 74 20 61 6c 6c 2e | related| at all.|
|000003f0| 20 59 6f 75 20 77 6f 6e | 27 74 20 0a 3e 20 3e 65 | You won|'t .> >e|
|00000400| 78 70 65 63 74 20 61 20 | 66 75 6e 63 74 69 6f 6e |xpect a |function|
|00000410| 20 6e 61 6d 65 64 20 70 | 72 69 6e 74 20 74 6f 20 | named p|rint to |
|00000420| 68 69 64 65 20 61 20 66 | 75 6e 63 74 69 6f 6e 20 |hide a f|unction |
|00000430| 6e 61 6d 65 64 20 72 65 | 61 64 2c 20 77 6f 75 6c |named re|ad, woul|
|00000440| 64 20 79 6f 75 3f 0a 3e | 20 0a 3e 20 54 68 69 73 |d you?.>| .> This|
|00000450| 20 72 75 6c 65 20 77 61 | 73 20 61 64 64 65 64 20 | rule wa|s added |
|00000460| 74 6f 20 70 72 65 76 65 | 6e 74 20 63 6f 6d 6d 6f |to preve|nt commo|
|00000470| 6e 20 70 72 6f 67 72 61 | 6d 6d 69 6e 67 20 65 72 |n progra|mming er|
|00000480| 72 6f 72 73 20 77 69 74 | 68 20 61 20 62 61 73 65 |rors wit|h a base|
|00000490| 20 63 6c 61 73 73 0a 3e | 20 66 75 6e 63 74 69 6f | class.>| functio|
|000004a0| 6e 20 67 65 74 74 69 6e | 67 20 63 61 6c 6c 65 64 |n gettin|g called|
|000004b0| 20 75 6e 65 78 70 65 63 | 74 65 64 6c 79 20 64 75 | unexpec|tedly du|
|000004c0| 65 20 74 6f 20 6f 76 65 | 72 6c 6f 61 64 69 6e 67 |e to ove|rloading|
|000004d0| 2e 0a 3e 20 0a 3e 20 49 | 66 20 61 20 64 65 72 69 |..> .> I|f a deri|
|000004e0| 76 65 64 20 63 6c 61 73 | 73 20 74 72 75 6c 79 20 |ved clas|s truly |
|000004f0| 77 61 6e 74 73 20 62 61 | 73 65 20 63 6c 61 73 73 |wants ba|se class|
|00000500| 20 66 75 6e 63 74 69 6f | 6e 73 20 77 69 74 68 20 | functio|ns with |
|00000510| 74 68 65 20 73 61 6d 65 | 20 6e 61 6d 65 0a 3e 20 |the same| name.> |
|00000520| 61 73 20 70 61 72 74 20 | 6f 66 20 69 74 73 20 69 |as part |of its i|
|00000530| 6e 74 65 72 66 61 63 65 | 2c 20 69 74 20 63 61 6e |nterface|, it can|
|00000540| 20 22 65 78 70 6f 72 74 | 22 20 74 68 65 6d 3a 0a | "export|" them:.|
|00000550| 3e 20 0a 3e 20 20 20 63 | 6c 61 73 73 20 42 3a 20 |> .> c|lass B: |
|00000560| 70 75 62 6c 69 63 20 41 | 20 7b 0a 3e 20 20 20 70 |public A| {.> p|
|00000570| 75 62 6c 69 63 3a 0a 3e | 20 20 20 20 20 76 6f 69 |ublic:.>| voi|
|00000580| 64 20 70 72 69 6e 74 28 | 63 6f 6e 73 74 20 54 20 |d print(|const T |
|00000590| 26 29 3b 0a 3e 20 20 20 | 20 20 76 6f 69 64 20 41 |&);.> | void A|
|000005a0| 3a 3a 70 72 69 6e 74 28 | 69 6e 74 29 3b 0a 3e 20 |::print(|int);.> |
|000005b0| 20 20 20 20 2e 2e 2e 0a | 3e 20 20 20 7d 0a 0a 0a | ....|> }...|
|000005c0| 49 6e 20 61 72 74 69 63 | 6c 65 20 3c 34 68 30 66 |In artic|le <4h0f|
|000005d0| 65 6c 24 70 72 75 40 6e | 65 77 73 2e 63 73 2e 74 |el$pru@n|ews.cs.t|
|000005e0| 75 2d 62 65 72 6c 69 6e | 2e 64 65 3e 20 79 6f 75 |u-berlin|.de> you|
|000005f0| 20 77 72 69 74 65 3a 0a | 3e 72 65 69 6d 70 6c 65 | write:.|>reimple|
|00000600| 6d 65 6e 74 65 64 20 66 | 75 6e 63 74 69 6f 6e 2e |mented f|unction.|
|00000610| 20 54 68 61 74 20 6d 65 | 61 6e 73 20 79 6f 75 20 | That me|ans you |
|00000620| 6e 65 65 64 20 61 20 71 | 75 61 6c 69 66 69 65 72 |need a q|ualifier|
|00000630| 3a 20 73 69 6d 70 6c 79 | 20 72 65 70 6c 61 63 65 |: simply| replace|
|00000640| 20 62 2e 70 72 69 6e 74 | 28 70 29 0a 3e 62 79 20 | b.print|(p).>by |
|00000650| 62 2e 41 3a 3a 70 72 69 | 6e 74 28 70 29 2c 20 69 |b.A::pri|nt(p), i|
|00000660| 2e 65 2e 20 74 65 6c 6c | 20 74 68 65 20 63 6f 6d |.e. tell| the com|
|00000670| 70 69 6c 65 72 20 74 6f | 20 63 61 6c 6c 20 41 27 |piler to| call A'|
|00000680| 73 20 66 75 6e 63 74 69 | 6f 6e 2e 20 0a 3e 49 20 |s functi|on. .>I |
|00000690| 74 68 69 6e 6b 20 74 68 | 69 73 20 69 73 20 61 20 |think th|is is a |
|000006a0| 73 65 72 69 6f 75 73 20 | 77 65 61 6b 6e 65 73 73 |serious |weakness|
|000006b0| 20 6f 66 20 74 68 65 20 | 6c 61 6e 67 75 61 67 65 | of the |language|
|000006c0| 20 73 69 6e 63 65 20 74 | 68 65 20 75 6e 69 71 75 | since t|he uniqu|
|000006d0| 65 20 69 64 65 6e 74 69 | 66 69 65 72 20 6f 66 20 |e identi|fier of |
|000006e0| 0a 3e 61 20 66 75 6e 63 | 74 69 6f 6e 20 69 73 20 |.>a func|tion is |
|000006f0| 28 20 6f 72 20 73 68 6f | 75 6c 64 20 62 65 20 29 |( or sho|uld be )|
|00000700| 20 69 74 73 20 6e 61 6d | 65 20 61 6e 64 20 74 68 | its nam|e and th|
|00000710| 65 20 74 79 70 65 73 20 | 6f 66 20 69 74 73 20 61 |e types |of its a|
|00000720| 72 67 75 6d 65 6e 74 73 | 2e 20 54 68 75 73 2c 20 |rguments|. Thus, |
|00000730| 74 68 65 0a 3e 66 75 6e | 63 74 69 6f 6e 73 20 70 |the.>fun|ctions p|
|00000740| 72 69 6e 74 28 69 6e 74 | 29 20 61 6e 64 20 70 72 |rint(int|) and pr|
|00000750| 69 6e 74 28 63 6f 6e 73 | 74 26 20 54 29 20 73 68 |int(cons|t& T) sh|
|00000760| 6f 75 6c 64 6e 27 74 20 | 62 65 20 72 65 6c 61 74 |ouldn't |be relat|
|00000770| 65 64 20 61 74 20 61 6c | 6c 2e 20 59 6f 75 20 77 |ed at al|l. You w|
|00000780| 6f 6e 27 74 20 0a 3e 65 | 78 70 65 63 74 20 61 20 |on't .>e|xpect a |
|00000790| 66 75 6e 63 74 69 6f 6e | 20 6e 61 6d 65 64 20 70 |function| named p|
|000007a0| 72 69 6e 74 20 74 6f 20 | 68 69 64 65 20 61 20 66 |rint to |hide a f|
|000007b0| 75 6e 63 74 69 6f 6e 20 | 6e 61 6d 65 64 20 72 65 |unction |named re|
|000007c0| 61 64 2c 20 77 6f 75 6c | 64 20 79 6f 75 3f 0a 0a |ad, woul|d you?..|
|000007d0| 54 68 69 73 20 72 75 6c | 65 20 77 61 73 20 61 64 |This rul|e was ad|
|000007e0| 64 65 64 20 74 6f 20 70 | 72 65 76 65 6e 74 20 63 |ded to p|revent c|
|000007f0| 6f 6d 6d 6f 6e 20 70 72 | 6f 67 72 61 6d 6d 69 6e |ommon pr|ogrammin|
|00000800| 67 20 65 72 72 6f 72 73 | 20 77 69 74 68 20 61 20 |g errors| with a |
|00000810| 62 61 73 65 20 63 6c 61 | 73 73 0a 66 75 6e 63 74 |base cla|ss.funct|
|00000820| 69 6f 6e 20 67 65 74 74 | 69 6e 67 20 63 61 6c 6c |ion gett|ing call|
|00000830| 65 64 20 75 6e 65 78 70 | 65 63 74 65 64 6c 79 20 |ed unexp|ectedly |
|00000840| 64 75 65 20 74 6f 20 6f | 76 65 72 6c 6f 61 64 69 |due to o|verloadi|
|00000850| 6e 67 2e 0a 0a 49 66 20 | 61 20 64 65 72 69 76 65 |ng...If |a derive|
|00000860| 64 20 63 6c 61 73 73 20 | 74 72 75 6c 79 20 77 61 |d class |truly wa|
|00000870| 6e 74 73 20 62 61 73 65 | 20 63 6c 61 73 73 20 66 |nts base| class f|
|00000880| 75 6e 63 74 69 6f 6e 73 | 20 77 69 74 68 20 74 68 |unctions| with th|
|00000890| 65 20 73 61 6d 65 20 6e | 61 6d 65 0a 61 73 20 70 |e same n|ame.as p|
|000008a0| 61 72 74 20 6f 66 20 69 | 74 73 20 69 6e 74 65 72 |art of i|ts inter|
|000008b0| 66 61 63 65 2c 20 69 74 | 20 63 61 6e 20 22 65 78 |face, it| can "ex|
|000008c0| 70 6f 72 74 22 20 74 68 | 65 6d 3a 0a 0a 20 20 63 |port" th|em:.. c|
|000008d0| 6c 61 73 73 20 42 3a 20 | 70 75 62 6c 69 63 20 41 |lass B: |public A|
|000008e0| 20 7b 0a 20 20 70 75 62 | 6c 69 63 3a 0a 20 20 20 | {. pub|lic:. |
|000008f0| 20 76 6f 69 64 20 70 72 | 69 6e 74 28 63 6f 6e 73 | void pr|int(cons|
|00000900| 74 20 54 20 26 29 3b 0a | 20 20 20 20 76 6f 69 64 |t T &);.| void|
|00000910| 20 41 3a 3a 70 72 69 6e | 74 28 69 6e 74 29 3b 0a | A::prin|t(int);.|
|00000920| 20 20 20 20 2e 2e 2e 0a | 20 20 7d 3b 0a 0a 0a 0a | ....| };....|
|00000930| 49 20 73 65 65 20 79 6f | 75 72 20 70 6f 69 6e 74 |I see yo|ur point|
|00000940| 20 62 75 74 20 73 74 69 | 6c 6c 2c 20 49 4d 50 20 | but sti|ll, IMP |
|00000950| 74 68 69 73 20 72 75 6c | 65 20 64 6f 65 73 20 6e |this rul|e does n|
|00000960| 6f 74 20 66 69 74 20 69 | 6e 20 74 68 65 20 67 65 |ot fit i|n the ge|
|00000970| 6e 65 72 61 6c 0a 6c 61 | 6e 67 75 61 67 65 20 63 |neral.la|nguage c|
|00000980| 6f 6e 63 65 70 74 2e 20 | 49 20 61 6d 20 6e 6f 74 |oncept. |I am not|
|00000990| 20 73 75 72 65 20 69 66 | 20 69 74 20 69 73 20 61 | sure if| it is a|
|000009a0| 70 70 72 6f 70 72 69 61 | 74 65 20 74 6f 20 73 61 |ppropria|te to sa|
|000009b0| 63 72 69 66 69 63 65 20 | 74 68 65 0a 63 6c 61 72 |crifice |the.clar|
|000009c0| 69 74 79 20 6f 66 20 61 | 20 6c 61 6e 67 75 61 67 |ity of a| languag|
|000009d0| 65 20 66 6f 72 20 70 72 | 6f 67 72 61 6d 6d 65 72 |e for pr|ogrammer|
|000009e0| 73 27 20 63 6f 6e 76 65 | 6e 69 65 6e 63 65 2e 20 |s' conve|nience. |
|000009f0| 49 66 20 49 20 64 65 63 | 6c 61 72 65 20 61 20 62 |If I dec|lare a b|
|00000a00| 61 73 65 0a 63 6c 61 73 | 73 20 41 0a 0a 63 6c 61 |ase.clas|s A..cla|
|00000a10| 73 73 20 41 0a 7b 0a 70 | 75 62 6c 69 63 3a 0a 20 |ss A.{.p|ublic:. |
|00000a20| 76 6f 69 64 20 66 6f 6f | 28 76 6f 69 64 29 3b 0a |void foo|(void);.|
|00000a30| 20 76 6f 69 64 20 66 6f | 6f 28 20 69 6e 74 20 29 | void fo|o( int )|
|00000a40| 3b 0a 20 76 6f 69 64 20 | 66 6f 6f 28 20 69 6e 74 |;. void |foo( int|
|00000a50| 2c 20 69 6e 74 20 29 3b | 0a 7d 3b 0a 0a 61 6e 64 |, int );|.};..and|
|00000a60| 20 61 20 64 65 72 69 76 | 65 64 20 63 6c 61 73 73 | a deriv|ed class|
|00000a70| 20 42 0a 0a 63 6c 61 73 | 73 20 42 20 3a 20 70 75 | B..clas|s B : pu|
|00000a80| 62 6c 69 63 20 41 0a 7b | 0a 70 75 62 6c 69 63 3a |blic A.{|.public:|
|00000a90| 0a 20 76 6f 69 64 20 66 | 6f 6f 28 20 69 6e 74 20 |. void f|oo( int |
|00000aa0| 29 3b 0a 7d 3b 0a 0a 61 | 6c 6c 20 66 6f 6f 2d 66 |);.};..a|ll foo-f|
|00000ab0| 75 6e 63 74 69 6f 6e 73 | 20 69 6e 20 41 20 61 72 |unctions| in A ar|
|00000ac0| 65 20 68 69 64 64 65 6e | 20 69 6e 20 42 20 65 76 |e hidden| in B ev|
|00000ad0| 65 6e 20 74 68 6f 75 67 | 68 20 74 68 65 79 20 68 |en thoug|h they h|
|00000ae0| 61 76 65 20 64 69 66 66 | 65 72 65 6e 74 0a 6e 75 |ave diff|erent.nu|
|00000af0| 6d 62 65 72 73 20 6f 66 | 20 61 72 67 75 6d 65 6e |mbers of| argumen|
|00000b00| 74 73 2e 20 48 6f 77 20 | 63 61 6e 20 6f 6e 65 20 |ts. How |can one |
|00000b10| 61 63 63 6f 75 6e 74 20 | 66 6f 72 20 74 68 69 73 |account |for this|
|00000b20| 3f 20 54 68 69 73 20 63 | 6f 6e 74 72 61 64 69 63 |? This c|ontradic|
|00000b30| 74 73 20 74 68 65 0a 63 | 6f 6e 63 65 70 74 20 6f |ts the.c|oncept o|
|00000b40| 66 20 73 63 6f 70 65 20 | 61 6e 64 20 63 61 6e 6e |f scope |and cann|
|00000b50| 6f 74 20 70 6f 73 73 69 | 62 6c 79 20 70 72 65 76 |ot possi|bly prev|
|00000b60| 65 6e 74 20 61 6e 79 20 | 65 72 72 6f 72 73 2e 20 |ent any |errors. |
|00000b70| 54 68 65 20 6d 61 69 6e | 0a 61 64 76 61 6e 74 61 |The main|.advanta|
|00000b80| 67 65 20 6f 66 20 6f 76 | 65 72 6c 6f 61 64 65 64 |ge of ov|erloaded|
|00000b90| 20 66 75 6e 63 74 69 6f | 6e 73 20 69 73 20 74 68 | functio|ns is th|
|00000ba0| 65 20 70 6f 73 73 69 62 | 69 6c 69 74 79 20 6f 66 |e possib|ility of|
|00000bb0| 20 64 65 66 69 6e 69 6e | 67 20 66 75 6e 63 74 69 | definin|g functi|
|00000bc0| 6f 6e 73 0a 77 69 74 68 | 20 74 68 65 20 73 61 6d |ons.with| the sam|
|00000bd0| 65 20 6e 61 6d 65 20 77 | 68 69 63 68 20 61 72 65 |e name w|hich are|
|00000be0| 20 69 6e 64 65 70 65 6e | 64 65 6e 74 20 6f 66 20 | indepen|dent of |
|00000bf0| 65 61 63 68 20 6f 74 68 | 65 72 2e 20 20 57 65 6c |each oth|er. Wel|
|00000c00| 6c 2c 20 69 66 20 41 0a | 63 6f 6e 74 61 69 6e 65 |l, if A.|containe|
|00000c10| 64 20 65 2e 67 2e 20 76 | 6f 69 64 20 66 6f 6f 28 |d e.g. v|oid foo(|
|00000c20| 20 63 68 61 72 20 29 20 | 70 72 6f 62 61 62 6c 79 | char ) |probably|
|00000c30| 20 73 6f 6d 65 20 65 72 | 72 6f 72 73 20 63 6f 75 | some er|rors cou|
|00000c40| 6c 64 20 62 65 20 61 76 | 6f 69 64 65 64 2e 0a 48 |ld be av|oided..H|
|00000c50| 6f 77 65 76 65 72 2c 20 | 69 6d 61 67 69 6e 65 20 |owever, |imagine |
|00000c60| 41 20 69 73 20 64 65 66 | 69 6e 65 64 20 69 6e 20 |A is def|ined in |
|00000c70| 61 20 63 6c 61 73 73 20 | 6c 69 62 72 61 72 79 20 |a class |library |
|00000c80| 79 6f 75 20 61 72 65 20 | 75 73 69 6e 67 20 61 6e |you are |using an|
|00000c90| 64 20 42 20 69 73 0a 79 | 6f 75 72 20 6f 77 6e 20 |d B is.y|our own |
|00000ca0| 63 72 65 61 74 69 6f 6e | 20 77 68 69 63 68 20 79 |creation| which y|
|00000cb0| 6f 75 20 77 61 6e 74 20 | 74 6f 20 72 65 75 73 65 |ou want |to reuse|
|00000cc0| 20 73 6f 6d 65 20 64 61 | 79 2e 20 59 6f 75 20 73 | some da|y. You s|
|00000cd0| 75 72 65 6c 79 20 77 61 | 6e 74 20 42 20 74 6f 0a |urely wa|nt B to.|
|00000ce0| 69 6e 68 65 72 69 74 20 | 61 6c 6c 20 74 68 65 20 |inherit |all the |
|00000cf0| 66 75 6e 63 74 69 6f 6e | 73 20 64 65 66 69 6e 65 |function|s define|
|00000d00| 64 20 69 6e 20 41 20 61 | 6e 64 2c 20 65 76 65 6e |d in A a|nd, even|
|00000d10| 20 6d 6f 72 65 2c 20 79 | 6f 75 20 70 72 6f 62 61 | more, y|ou proba|
|00000d20| 62 6c 79 20 77 61 6e 74 | 0a 74 6f 20 75 73 65 20 |bly want|.to use |
|00000d30| 74 68 65 6d 20 69 6e 20 | 42 27 73 20 69 6d 70 6c |them in |B's impl|
|00000d40| 65 6d 65 6e 74 61 74 69 | 6f 6e 2e 20 4e 6f 77 20 |ementati|on. Now |
|00000d50| 79 6f 75 20 67 6f 20 6f | 6e 2c 20 6f 76 65 72 6c |you go o|n, overl|
|00000d60| 6f 61 64 20 76 6f 69 64 | 20 66 6f 6f 28 20 69 6e |oad void| foo( in|
|00000d70| 74 0a 29 2c 20 77 72 69 | 74 65 20 79 6f 75 72 20 |t.), wri|te your |
|00000d80| 63 6f 64 65 20 61 6e 64 | 20 67 65 74 20 61 20 77 |code and| get a w|
|00000d90| 68 6f 6c 65 20 6c 6f 74 | 20 6f 66 20 65 72 72 6f |hole lot| of erro|
|00000da0| 72 20 6d 65 73 73 61 67 | 65 73 20 62 65 63 61 75 |r messag|es becau|
|00000db0| 73 65 20 79 6f 75 20 63 | 61 6c 6c 0a 6f 74 68 65 |se you c|all.othe|
|00000dc0| 72 20 66 6f 6f 20 66 75 | 6e 63 74 69 6f 6e 73 20 |r foo fu|nctions |
|00000dd0| 69 6e 20 79 6f 75 72 20 | 63 6f 64 65 2e 20 59 6f |in your |code. Yo|
|00000de0| 75 20 68 61 76 65 20 74 | 6f 20 6c 6f 6f 6b 20 75 |u have t|o look u|
|00000df0| 70 20 74 68 65 20 65 78 | 61 63 74 20 64 65 66 69 |p the ex|act defi|
|00000e00| 6e 69 74 69 6f 6e 0a 6f | 66 20 41 20 61 6e 64 20 |nition.o|f A and |
|00000e10| 22 65 78 70 6f 72 74 22 | 20 65 76 65 72 79 20 66 |"export"| every f|
|00000e20| 75 6e 63 74 69 6f 6e 20 | 77 69 74 68 20 74 68 65 |unction |with the|
|00000e30| 20 6e 61 6d 65 20 22 66 | 6f 6f 22 20 69 6e 20 42 | name "f|oo" in B|
|00000e40| 27 73 20 69 6e 74 65 72 | 66 61 63 65 2e 0a 54 68 |'s inter|face..Th|
|00000e50| 65 6e 20 79 6f 75 20 66 | 6f 72 67 65 74 20 74 68 |en you f|orget th|
|00000e60| 65 20 6f 6e 65 20 79 6f | 75 20 64 6f 6e 27 74 20 |e one yo|u don't |
|00000e70| 63 61 6c 6c 20 69 6e 20 | 79 6f 75 72 20 69 6d 70 |call in |your imp|
|00000e80| 6c 65 6d 65 6e 74 61 74 | 69 6f 6e 2c 20 66 69 6e |lementat|ion, fin|
|00000e90| 69 73 68 20 79 6f 75 72 | 0a 63 6c 61 73 73 20 42 |ish your|.class B|
|00000ea0| 2c 20 77 72 69 74 65 20 | 74 68 65 20 64 6f 63 75 |, write |the docu|
|00000eb0| 6d 65 6e 74 61 74 69 6f | 6e 20 61 6e 64 20 67 69 |mentatio|n and gi|
|00000ec0| 76 65 20 74 68 65 20 73 | 74 75 66 66 20 74 6f 20 |ve the s|tuff to |
|00000ed0| 79 6f 75 72 20 66 72 69 | 65 6e 64 2e 20 59 6f 75 |your fri|end. You|
|00000ee0| 72 0a 66 72 69 65 6e 64 | 20 72 65 6c 69 65 73 20 |r.friend| relies |
|00000ef0| 6f 6e 20 42 20 68 61 76 | 69 6e 67 20 74 68 65 20 |on B hav|ing the |
|00000f00| 66 75 6e 63 74 69 6f 6e | 20 79 6f 75 20 66 6f 72 |function| you for|
|00000f10| 67 6f 74 2c 20 63 61 6c | 6c 73 20 69 74 20 61 6e |got, cal|ls it an|
|00000f20| 64 20 67 65 74 73 20 61 | 6e 0a 65 72 72 6f 72 20 |d gets a|n.error |
|00000f30| 6d 65 73 73 61 67 65 20 | 68 65 20 64 6f 65 73 6e |message |he doesn|
|00000f40| 27 74 20 75 6e 64 65 72 | 73 74 61 6e 64 2e 20 4e |'t under|stand. N|
|00000f50| 6f 77 20 68 65 20 68 61 | 73 20 74 6f 20 6c 6f 6f |ow he ha|s to loo|
|00000f60| 6b 20 75 70 20 42 27 73 | 20 69 6e 74 65 72 66 61 |k up B's| interfa|
|00000f70| 63 65 2c 0a 74 68 65 6e | 20 41 27 73 20 69 6e 74 |ce,.then| A's int|
|00000f80| 65 72 66 61 63 65 20 61 | 6e 64 20 74 68 65 6e 20 |erface a|nd then |
|00000f90| 68 65 20 63 61 6c 6c 73 | 20 79 6f 75 20 61 6e 64 |he calls| you and|
|00000fa0| 20 74 65 6c 6c 73 20 79 | 6f 75 20 61 62 6f 75 74 | tells y|ou about|
|00000fb0| 20 74 68 65 20 6d 65 73 | 73 2e 20 41 6e 64 0a 73 | the mes|s. And.s|
|00000fc0| 6f 20 6f 6e 2e 2e 2e 20 | 49 20 74 68 69 6e 6b 20 |o on... |I think |
|00000fd0| 74 68 61 74 20 74 68 69 | 73 20 72 75 6c 65 20 63 |that thi|s rule c|
|00000fe0| 61 6e 20 70 72 6f 64 75 | 63 65 20 6d 6f 72 65 20 |an produ|ce more |
|00000ff0| 65 72 72 6f 72 73 20 74 | 68 61 6e 20 69 74 20 70 |errors t|han it p|
|00001000| 72 65 76 65 6e 74 73 2e | 0a 50 65 72 73 6f 6e 61 |revents.|.Persona|
|00001010| 6c 6c 79 2c 20 49 27 6d | 20 77 6f 72 6b 69 6e 67 |lly, I'm| working|
|00001020| 20 77 69 74 68 20 61 20 | 63 6c 61 73 73 20 6c 69 | with a |class li|
|00001030| 62 72 61 72 79 20 66 6f | 72 20 4d 53 2d 57 69 6e |brary fo|r MS-Win|
|00001040| 64 6f 77 73 2e 20 49 74 | 20 64 65 66 69 6e 65 73 |dows. It| defines|
|00001050| 20 61 0a 63 6c 61 73 73 | 20 22 57 69 6e 64 6f 77 | a.class| "Window|
|00001060| 22 20 77 68 69 63 68 20 | 65 6e 63 61 70 73 75 6c |" which |encapsul|
|00001070| 61 74 65 73 20 74 68 65 | 20 41 50 49 20 66 75 6e |ates the| API fun|
|00001080| 63 74 69 6f 6e 73 2e 20 | 4f 66 20 63 6f 75 72 73 |ctions. |Of cours|
|00001090| 65 2c 20 74 68 65 20 6d | 65 6d 62 65 72 0a 66 75 |e, the m|ember.fu|
|000010a0| 6e 63 74 69 6f 6e 73 20 | 68 61 76 65 20 74 68 65 |nctions |have the|
|000010b0| 20 73 61 6d 65 20 6e 61 | 6d 65 2e 20 48 6f 77 65 | same na|me. Howe|
|000010c0| 76 65 72 2c 20 49 20 6f | 66 74 65 6e 20 6e 65 65 |ver, I o|ften nee|
|000010d0| 64 20 74 6f 20 63 61 6c | 6c 20 61 6e 20 41 50 49 |d to cal|l an API|
|000010e0| 0a 66 75 6e 63 74 69 6f | 6e 20 64 69 72 65 63 74 |.functio|n direct|
|000010f0| 6c 79 2c 20 66 72 6f 6d | 20 74 68 65 20 6d 65 6d |ly, from| the mem|
|00001100| 62 65 72 20 66 75 6e 63 | 74 69 6f 6e 73 20 6f 66 |ber func|tions of|
|00001110| 20 57 69 6e 64 6f 77 20 | 61 6e 64 20 6f 66 20 63 | Window |and of c|
|00001120| 6f 75 72 73 65 20 49 0a | 75 73 75 61 6c 6c 79 20 |ourse I.|usually |
|00001130| 66 6f 72 67 65 74 20 74 | 68 65 20 22 3a 3a 22 2e |forget t|he "::".|
|00001140| 20 4f 6e 20 74 68 65 20 | 6f 74 68 65 72 20 68 61 | On the |other ha|
|00001150| 6e 64 2c 20 49 20 68 61 | 76 65 6e 27 74 20 68 61 |nd, I ha|ven't ha|
|00001160| 64 20 61 20 73 69 74 75 | 61 74 69 6f 6e 0a 77 68 |d a situ|ation.wh|
|00001170| 65 72 65 20 74 68 69 73 | 20 72 75 6c 65 20 77 61 |ere this| rule wa|
|00001180| 73 20 68 65 6c 70 66 75 | 6c 20 69 6e 20 73 6f 6d |s helpfu|l in som|
|00001190| 65 20 77 61 79 2e 20 0a | 0a 0a 42 79 65 0a 0a 52 |e way. .|..Bye..R|
|000011a0| 6f 6d 61 6e 0a 0a 0a 0a | 20 0a |oman....| . |
+--------+-------------------------+-------------------------+--------+--------+